import React from 'react'
 
export default function Count({sum, increment, decrement, incrementAsync}) {
  const addIfOdd = () => {
    if(sum%2 !== 0) {
      increment(1)
    }
  }
  return (
    <div>
      <h3>总和: {sum}</h3>
      
      <button onClick={() => increment(1)}>加</button>
      <button onClick={() => decrement(1)}>减</button>
      <button onClick={addIfOdd}>奇数加</button>
      <button onClick={() => incrementAsync(1, 500)}>异步加</button>
    </div>

  )
}
